package org.practice.proxy.dynamic;

import java.lang.reflect.Proxy;

/**
 * 返回动态代理类
 */
public class DynamicProxyFactory {
	//返回BusinessDao接口实现类的动态代理对象
	public static BusinessDao getBusinessDao(){
		BusinessDaoImpl targetObj=new BusinessDaoImpl();
		BusinessInvocationHandler handler=new BusinessInvocationHandler(targetObj);
		BusinessDao proxyObj=(BusinessDao)Proxy.newProxyInstance(BusinessDao.class.getClassLoader(),new Class[]{BusinessDao.class},handler);
		return proxyObj;
	}
}
